﻿@using MvcPaging
@using QuocHoi_TV_Frontend.Models
@model IPagedList<QuocHoi_TV_Frontend.Models.News>
 
<ul class="">

    @foreach (var itemNews in Model)
    {
        string strlinknewsbycate = Url.RouteUrl("NewsDetail",
                                          new
                                          {
                                              controller = "News",
                                              action = "NewsDetailHome",
                                              cate_name = Util.RemoveSign4VietnameseString(itemNews.Category.CateName),
                                              year = DateTime.Parse(itemNews.CreateDate.ToString()).Year,
                                              month = DateTime.Parse(itemNews.CreateDate.ToString()).Month,
                                              news_title = Util.RemoveSign4VietnameseString(itemNews.NewsTitle),
                                              newsID = itemNews.NewsID
                                          }
                                           );
        string newsTitle = Util.RemoveSign4VietnameseString(itemNews.NewsTitle); 
        <li class="newsofweek">
            <div class="img_newsofweek">
                <a href="@Html.Raw(strlinknewsbycate)">
                    <img src="@itemNews.PathImgSmall"width="302" height="170" />
                </a>
            </div>
            <div class="tilebold">
                <a href="@Html.Raw(strlinknewsbycate)">@Html.Raw(NewsHelper.Sliptsubject(itemNews.NewsTitle, 60))</a>
            </div>
            <p class="infonewsofweek">
                @NewsHelper.Sliptsubject(itemNews.NewSub, 100)
            </p>
        </li>
    }
</ul>

<div class="pagenewsofweek">
    @Html.Raw(Ajax.Pager(
            new Options
            {
                PageSize = Model.PageSize,
                TotalItemCount = Model.TotalItemCount,
                CurrentPage = Model.PageNumber,
                ItemTexts = new ItemTexts() { Next = "", Previous = "", Page = "", First = "", Last = "" },
                ItemIcon = new ItemIcon() { First = "icon-backward", Previous = "icon-chevron-left", Next = "icon-chevron-right", Last = "icon-forward" },
               
                Size = Size.normal,
                Alignment = Alignment.right,
                IsShowControls = true,
                CssClass="pagination-home"
                

            },
            new AjaxOptions
            {
                UpdateTargetId = "lstnewsbydate",
                OnBegin = "beginPaging",
                OnSuccess = "successPaging",
                OnFailure = "failurePaging"
            }, new { controller = "Default", action = "Home", date = ViewData["date"], active = ViewData["active"] }))

</div>
<script type="text/javascript">
    function beginPaging(args) {
        // Animate
        //$('#grid-list').fadeOut('normal');
    }

    function successPaging() {
        // Animate
        //$('#grid-list').fadeIn('normal');
        //$('a').tooltip();
    }

    function failurePaging() {
        alert("Could not retrieve list.");
    }
</script>
